package com.cskaoyan.bean;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 类<code>Doc</code>用于：TODO
 *
 * @author Acher
 * @version 1.0
 * @date 2021-10-12
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    private int code;
    private String msg;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private T data;

    public static Result<?> ok(Object data) {
        return new Result<>(0, null, data);
    }

    public static Result<?> ok() {
        return new Result<>(0, null, null);
    }

    public static Result<?> error(String msg) {
        return new Result<>(0, msg, null);
    }
}
